<div id="tab10" class="tab">
    <div class="tab-labels">
        <div class="xian"></div>
        理算
    </div>
    <form action="" id="lisuan">
        <input type="hidden" name="bid" value="{$row.id}">
        <input type="hidden" name="type" value="{$type}">
        <input type="hidden" name="sid" value="{$orderid}">
        <input type="hidden" name="sid" value="{$orderid}">
        <button type="button" class="layui-btn layui-btn-radius layui-btn-x" id="load_zong">加载数据</button>
        <table class="layui-table">
            <tr style="background:#4e73df;color: #fff;" class="ys">
                <td></td>
                <td>本车损失</td>
                <td>本车人伤</td>
                <td>三者车损失</td>
                <td>三者物损</td>
                <td>三者车人伤</td>
            </tr>
            <tr>
                <td>金额</td>

                <td><input type="text" name="benche_money" class="benche_money"
                           value="<?php if(!empty($lisuan['benche_money'])){ echo $lisuan['benche_money']; }else{ echo floatval($row['hd_benche_zongji']) + floatval($row['hd_bengong_zongji']); }?>"
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_money" class="benshang_money"
                           value="<?php if(!empty($lisuan['benshang_money'])){ echo $lisuan['benshang_money']; }else{ if(!empty($benren)){ echo $hd_sum; } }?>"
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_money" class="sanche_money"
                           value="<?php if(!empty($lisuan['sanche_money'])){ echo $lisuan['sanche_money']; }else{ if(!empty($sanchess)){ echo floatval($sanchess['hd_p_zongji'])+floatval($sanchess['hd_g_zongji'])+floatval($sanchess['hd_g_shijiu']); } }?>"
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_money" class="sanwu_money"
                           value="<?php if(!empty($lisuan['sanwu_money'])){ echo $lisuan['sanwu_money']; }else{ if(!empty($scwusun)){ echo $scwusun[0]['hd_c_zongji']; } }?>"
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_money" class="sanshang_money"
                           value="<?php if(!empty($lisuan['sanshang_money'])){ echo $lisuan['sanshang_money']; }else{ if(!empty($sanren)){ echo $hd_sum; } }?>"
                           oninput="vu()"></td>
            </tr>
            <?php if(!empty($lisuan)) {?>
            <tr>
                <td>免赔额</td>
                <td><input type="text" name="benche_miane" class="benche_miane" value="{$lisuan.benche_miane}"
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_miane" class="benshang_miane" value="{$lisuan.benshang_miane}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_miane" class="sanche_miane" value="{$lisuan.sanche_miane}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_miane" class="sanwu_miane" value="{$lisuan.sanwu_miane}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_miane" class="sanshang_miane" value="{$lisuan.sanshang_miane}"
                           oninput="vu()"></td>

            </tr>
            <tr>
                <td>免赔率(%)</td>
                <td><input type="text" name="benche_mianlv" class="benche_mianlv" value="{$lisuan.benche_mianlv}"
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_mianlv" class="benshang_mianlv" value="{$lisuan.benshang_mianlv}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_mianlv" class="sanche_mianlv" value="{$lisuan.sanche_mianlv}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_mianlv" class="sanwu_mianlv" value="{$lisuan.sanwu_mianlv}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_mianlv" class="sanshang_mianlv" value="{$lisuan.sanshang_mianlv}"
                           oninput="vu()"></td>
            </tr>
            <tr>
                <td>事故责任(%)</td>
                <td><input type="text" name="benche_zeren" class="benche_zeren"
                           value="{eq name='$lisuan.benche_zeren' value=''}{else/}{$lisuan.benche_zeren}{/eq}"
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_zeren" class="benshang_zeren"
                           value="{eq name='$lisuan.benshang_zeren' value=''}{else/}{$lisuan.benshang_zeren}{/eq}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_zeren" class="sanche_zeren"
                           value="{eq name='$lisuan.sanche_zeren' value=''}{else/}{$lisuan.sanche_zeren}{/eq}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_zeren" class="sanwu_zeren"
                           value="{eq name='$lisuan.sanwu_zeren' value=''}{else/}{$lisuan.sanwu_zeren}{/eq}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_zeren" class="sanshang_zeren"
                           value="{eq name='$lisuan.sanshang_zeren' value=''}{else/}{$lisuan.sanshang_zeren}{/eq}"
                           oninput="vu()"></td>
            </tr>
            <tr>
                <td>交强险</td>
                <td><input type="text" name="benche_qiangxian" class="benche_qiangxian"
                           value="{$lisuan.benche_qiangxian}" oninput="vu()"></td>
                <td><input type="text" name="benshang_qiangxian" class="benshang_qiangxian"
                           value="{$lisuan.benshang_qiangxian}" oninput="vu()"></td>
                <td><input type="text" name="sanche_qiangxian" class="sanche_qiangxian"
                           value="{$lisuan.sanche_qiangxian}" oninput="vu()"></td>
                <td><input type="text" name="sanwu_qiangxian" class="sanwu_qiangxian" value="{$lisuan.sanwu_qiangxian}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_qiangxian" class="sanshang_qiangxian"
                           value="{$lisuan.sanshang_qiangxian}" oninput="vu()"></td>
            </tr>
            <tr>
                <td>其他</td>
                <td><input type="text" name="benche_qita" class="benche_qita" value="{$lisuan.benche_qita}"
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_qita" class="benshang_qita" value="{$lisuan.benshang_qita}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_qita" class="sanche_qita" value="{$lisuan.sanche_qita}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_qita" class="sanwu_qita" value="{$lisuan.sanwu_qita}" oninput="vu()">
                </td>
                <td><input type="text" name="sanshang_qita" class="sanshang_qita" value="{$lisuan.sanshang_qita}"
                           oninput="vu()"></td>
            </tr>
            <tr>
                <td>合计</td>
                <td><input type="text" name="benche_heji" class="benche_heji" value="{$lisuan.benche_heji}"
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_heji" class="benshang_heji" value="{$lisuan.benshang_heji}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_heji" class="sanche_heji" value="{$lisuan.sanche_heji}"
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_heji" class="sanwu_heji" value="{$lisuan.sanwu_heji}" oninput="vu()">
                </td>
                <td><input type="text" name="sanshang_heji" class="sanshang_heji" value="{$lisuan.sanshang_heji}"
                           oninput="vu()"></td>
            </tr>
            <?php }else{ ?>
            <tr>
                <td>免赔额</td>
                <td><input type="text" name="benche_miane" class="benche_miane" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_miane" class="benshang_miane" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_miane" class="sanche_miane" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_miane" class="sanwu_miane" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_miane" class="sanshang_miane" value=""
                           oninput="vu()"></td>

            </tr>
            <tr>
                <td>免赔率(%)</td>
                <td><input type="text" name="benche_mianlv" class="benche_mianlv" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_mianlv" class="benshang_mianlv" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_mianlv" class="sanche_mianlv" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_mianlv" class="sanwu_mianlv" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_mianlv" class="sanshang_mianlv" value=""
                           oninput="vu()"></td>
            </tr>
            <tr>
                <td>事故责任(%)</td>
                <td><input type="text" name="benche_zeren" class="benche_zeren"
                           value=""
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_zeren" class="benshang_zeren"
                           value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_zeren" class="sanche_zeren"
                           value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_zeren" class="sanwu_zeren"
                           value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_zeren" class="sanshang_zeren"
                           value=""
                           oninput="vu()"></td>
            </tr>
            <tr>
                <td>交强险</td>
                <td><input type="text" name="benche_qiangxian" class="benche_qiangxian"
                           value="" oninput="vu()"></td>
                <td><input type="text" name="benshang_qiangxian" class="benshang_qiangxian"
                           value="" oninput="vu()"></td>
                <td><input type="text" name="sanche_qiangxian" class="sanche_qiangxian"
                           value="" oninput="vu()"></td>
                <td><input type="text" name="sanwu_qiangxian" class="sanwu_qiangxian" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanshang_qiangxian" class="sanshang_qiangxian"
                           value="" oninput="vu()"></td>
            </tr>
            <tr>
                <td>其他</td>
                <td><input type="text" name="benche_qita" class="benche_qita" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_qita" class="benshang_qita" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_qita" class="sanche_qita" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_qita" class="sanwu_qita" value="" oninput="vu()">
                </td>
                <td><input type="text" name="sanshang_qita" class="sanshang_qita" value=""
                           oninput="vu()"></td>
            </tr>
            <tr>
                <td>合计</td>
                <td><input type="text" name="benche_heji" class="benche_heji" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="benshang_heji" class="benshang_heji" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanche_heji" class="sanche_heji" value=""
                           oninput="vu()"></td>
                <td><input type="text" name="sanwu_heji" class="sanwu_heji" value="" oninput="vu()">
                </td>
                <td><input type="text" name="sanshang_heji" class="sanshang_heji" value=""
                           oninput="vu()"></td>
            </tr>
            <?php } ?>
        </table>

        <?php if(!empty($lisuan)) {?>
        <div class="conts">
            <input type="hidden" value="{$row.benche_huizong}" id="benche_huizong">
            <input type="hidden" value="{$row.sc_huizong}" id="sc_huizong">
            <input type="hidden" value="{$row.sanren_heji}" id="sr_heji">
            <input type="hidden" value="{$row.benren_heji}" id="br_heji">
            <div class="input">
                <span>其他费用</span>
                <input type="text" name="qita" id="qita" value="{$lisuan.qita}" placeholder="其他费用" readonly>
            </div>
            <div class="input">
                <span>本车合计</span>
                <input type="text" name="b_heji" class="b_heji" value="{$lisuan.b_heji}" placeholder="本车合计">
                <!--oninput="vu()"-->
            </div>
            <div class="input">
                <span>三者车合计</span>
                <input type="text" name="s_heji" class="s_heji" value="{$lisuan.s_heji}" placeholder="三车合计">
            </div>
            <div class="input">
                <span>总计</span>
                <input type="text" name="zongji" class="zongji" value="{$lisuan.zongji}" placeholder="总计">
            </div>
        </div>
        <div class="conts">
            <span style="width:98%;margin: 1%;">备注意见</span>
            <textarea name="beizhu" cols="30" rows="10"
                      style="width:98%;height: 150px;margin: 1%;">{$lisuan.beizhu}</textarea>
        </div>
        <?php }else{ ?>
        <div class="conts">
            <input type="hidden" value="{$row.benche_huizong}" id="benche_huizong">
            <input type="hidden" value="{$row.sc_huizong}" id="sc_huizong">
            <input type="hidden" value="{$row.sanren_heji}" id="sr_heji">
            <input type="hidden" value="{$row.benren_heji}" id="br_heji">
            <div class="input">
                <span>其他费用</span>
                <input type="text" name="qita" id="qita" value="" placeholder="其他费用" readonly>
            </div>
            <div class="input">
                <span>本车合计</span>
                <input type="text" name="b_heji" class="b_heji" value="" placeholder="本车合计">
                <!--oninput="vu()"-->
            </div>
            <div class="input">
                <span>三者车合计</span>
                <input type="text" name="s_heji" class="s_heji" value="" placeholder="三车合计">
            </div>
            <div class="input">
                <span>总计</span>
                <input type="text" name="zongji" class="zongji" value="" placeholder="总计">
            </div>
        </div>
        <div class="conts">
            <span style="width:98%;margin: 1%;">备注意见</span>
            <textarea name="beizhu" cols="30" rows="10"
                      style="width:98%;height: 150px;margin: 1%;"></textarea>
        </div>
        <?php } ?>
        <script>
            // var benche_huizong = document.getElementById('benche_huizong').value;
            // var sc_huizong = document.getElementById('sc_huizong').value;
            // var sr_heji = document.getElementById('sr_heji').value;
            // var br_heji = document.getElementById('br_heji').value;
            // var qita = document.getElementById('qita');
            // if (benche_huizong == ''){
            //     benche_huizong = 0;
            // }
            // if (sc_huizong == ''){
            //     sc_huizong = 0;
            // }
            // if (sr_heji == '') {
            //     sr_heji = 0;
            // }
            // if (br_heji == ''){
            //     br_heji = 0;
            // }
            // qita.value = parseFloat(benche_huizong)+parseFloat(sc_huizong)+parseFloat(sr_heji)+parseFloat(br_heji);
        </script>
        <div class="bao" style="width:400px;height: 30px;margin:20px auto;">
            <button type="button" onclick="lisuan()"
                    style="width:60px;height:100%; float:left;border: none;background:#1b4fe7;color: #fff;-webkit-border-radius:5px ;-moz-border-radius:5px ;border-radius: 5px;">
                保存
            </button>

            <!-- <button type="button" onclick="p_lisuan()" style="width:60px;height:100%;margin-left:10px; float:left;border: none;background:#1b4fe7;color: #fff;-webkit-border-radius:5px ;-moz-border-radius:5px ;border-radius: 5px;">打印</button> -->
            <button type="button"
                    style="width:60px;height:100%;margin-left:10px; float:left;border: none;background:#1b4fe7;color: #fff;-webkit-border-radius:5px ;-moz-border-radius:5px ;border-radius: 5px;"
                    onclick="window.open('lisuandayin?id={$row.id}&sid={$orderid}&type={$type}','_blank')"
                    class="do-btn-print">打印
            </button>
        </div>
        <script>
            function p_lisuan() {
                var id = document.getElementById('id').value;
                window.location.href = 'lisuandayin?id=' + id;
            }

            //加载数据-----------------------------Edit By zhi-------------Start
            $('#load_zong').click(function () {
                vu();
            })

            //加载数据-----------------------------Edit By zhi-------------End
            function vu() {
                //（金额-交强险）×（1-免赔率%）×事故责任%-免赔额+其他=合计
                var sum = 0;
                // 本车损失
                var benche_money = $($(".benche_money")[0]).val();
                var benche_miane = $($(".benche_miane")[0]).val();
                var benche_mianlv = $($(".benche_mianlv")[0]).val();
                var benche_zeren = $($(".benche_zeren")[0]).val();
                var benche_qiangxian = $($(".benche_qiangxian")[0]).val();
                var benche_qita = $($(".benche_qita")[0]).val();
                sum = (Number(benche_money) - Number(benche_qiangxian)) * (1 - (Number(benche_mianlv) / 100)) * (Number(benche_zeren) / 100) - Number(benche_miane) + Number(benche_qita);
                $($(".benche_heji")[0]).val(sum.toFixed(2));
                // 本车人伤
                sum = 0;
                var benshang_money = $($(".benshang_money")[0]).val();
                var benshang_miane = $($(".benshang_miane")[0]).val();
                var benshang_mianlv = $($(".benshang_mianlv")[0]).val();
                var benshang_zeren = $($(".benshang_zeren")[0]).val();
                var benshang_qiangxian = $($(".benshang_qiangxian")[0]).val();
                var benshang_qita = $($(".benshang_qita")[0]).val();
                sum = (Number(benshang_money) - Number(benshang_qiangxian)) * (1 - (Number(benshang_mianlv) / 100)) * (Number(benshang_zeren) / 100) - Number(benshang_miane) + Number(benshang_qita);
                $($(".benshang_heji")[0]).val(sum.toFixed(2));
                // 三者车损失
                sum = 0;
                var sanche_money = $($(".sanche_money")[0]).val();
                var sanche_miane = $($(".sanche_miane")[0]).val();
                var sanche_mianlv = $($(".sanche_mianlv")[0]).val();
                var sanche_zeren = $($(".sanche_zeren")[0]).val();
                var sanche_qiangxian = $($(".sanche_qiangxian")[0]).val();
                var sanche_qita = $($(".sanche_qita")[0]).val();
                sum = (Number(sanche_money) - Number(sanche_qiangxian)) * (1 - (Number(sanche_mianlv) / 100)) * (Number(sanche_zeren) / 100) - Number(sanche_miane) + Number(sanche_qita);
                $($(".sanche_heji")[0]).val(sum.toFixed(2));
                // 三者物损
                sum = 0;
                var sanwu_money = $($(".sanwu_money")[0]).val();
                var sanwu_miane = $($(".sanwu_miane")[0]).val();
                var sanwu_mianlv = $($(".sanwu_mianlv")[0]).val();
                var sanwu_zeren = $($(".sanwu_zeren")[0]).val();
                var sanwu_qiangxian = $($(".sanwu_qiangxian")[0]).val();
                var sanwu_qita = $($(".sanwu_qita")[0]).val();
                sum = (Number(sanwu_money) - Number(sanwu_qiangxian)) * (1 - (Number(sanwu_mianlv) / 100)) * (Number(sanwu_zeren) / 100) - Number(sanwu_miane) + Number(sanwu_qita);
                $($(".sanwu_heji")[0]).val(sum.toFixed(2));
                // 三者车人伤
                sum = 0;
                var sanshang_money = $($(".sanshang_money")[0]).val();
                var sanshang_miane = $($(".sanshang_miane")[0]).val();
                var sanshang_mianlv = $($(".sanshang_mianlv")[0]).val();
                var sanshang_zeren = $($(".sanshang_zeren")[0]).val();
                var sanshang_qiangxian = $($(".sanshang_qiangxian")[0]).val();
                var sanshang_qita = $($(".sanshang_qita")[0]).val();
                sum = (Number(sanshang_money) - Number(sanshang_qiangxian)) * (1 - (Number(sanshang_mianlv) / 100)) * (Number(sanshang_zeren) / 100) - Number(sanshang_miane) + Number(sanshang_qita);
                $($(".sanshang_heji")[0]).val(sum.toFixed(2));
                //
                $("#qita").val(Number(benche_qita) + Number(benshang_qita) + Number(sanche_qita) + Number(sanwu_qita) + Number(sanshang_qita));
                console.log(Number($($(".benche_heji")[0]).val()) + Number($($(".benshang_heji")[0]).val()));
                $($(".b_heji")[0]).val(Number($($(".benche_heji")[0]).val()) + Number($($(".benshang_heji")[0]).val()));
                $($(".s_heji")[0]).val(Number($($(".sanche_heji")[0]).val()) + Number($($(".sanwu_heji")[0]).val()) + Number($($(".sanshang_heji")[0]).val()));
                $($(".zongji")[0]).val(Number($($(".b_heji")[0]).val()) + Number($($(".s_heji")[0]).val()));
            }

            function lisuan() {

                $.ajax({
                    //几个参数需要注意一下
                    type: "POST",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "{:url('bushen/lisuan/lisuan')}",//url
                    data: $('#lisuan').serialize(),
                    success: function (res) {
                        layer.msg(res.msg);
                    }
                });
            }

            function lisuan1() {

                $.ajax({
                    //几个参数需要注意一下
                    type: "POST",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "{:url('bushen/lisuan/lisuan')}",//url
                    data: $('#lisuan').serialize(),
                    success: function (res) {
                        // layer.msg(res.msg);
                    }
                });
            }
        </script>
    </form>
</div>